angular.module('liemallfodder')
    .service('Loading', function ($rootScope, $ionicLoading) {

        this.show = function () {
            if (!$rootScope.showLoading) {
                $rootScope.showLoading = true;
            }
        };

        this.hide = function () {
            if ($rootScope.showLoading) {
                $rootScope.showLoading = false;
            }
        };

        this.isShowing = function () {
            return $rootScope.showLoading;
        };

        this.showBlockLoading = function (message) {
            $ionicLoading.show({
                template: message ? message : '正在加载'
            }).then(function () {
                console.log("The loading indicator is now displayed");
            });
        };

        this.hideBlockLoading = function () {
            $ionicLoading.hide().then(function () {
                console.log("The loading indicator is now hidden");
            });
        };

    });
